<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../component/pear/css/pear.css"/>
    <style>
        .layui-form-select dl{
            max-height: 180px;
        }
    </style>
</head>
<body>
<form class="layui-form" action="" style="padding-right: 30px">
    <div class="main-container">
        <div class="layui-row layui-col-space1">
            <div class="layui-col-md12">
                <input type="hidden" id="personid" name="id" value="${busPerson.id!}">
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="pname" lay-verify="required" required placeholder="" autocomplete="off"
                                   class="layui-input" value="${busPerson.pname!}">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">性别</label>
                        <div class="layui-input-block">
                            <input type="radio" name="sex" if(${(busPerson.sex!)}==''){ checked } ${busPerson.sex!0==0?"checked":""} value="0"
                                   title="男">
                            <input type="radio" name="sex" ${busPerson.sex!0==1?"checked":""} value="1"
                                   title="女">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">手机号</label>
                        <div class="layui-input-block">
                            <input type="text" name="phone" lay-verify="required|phone"  placeholder=""  autocomplete="off"
                                   class="layui-input" value="${busPerson.phone!}">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">单位</label>
                        <div class="layui-input-block">
                            <select name="unit" lay-verify="required" lay-search="">
                                <option value="" selected>请选择</option>
                                @for(item in dwList!){
                                <option value="${item.id}" ${item.id==(busPerson.unit!)?'selected':''}>${item.name!}</option>
                                @}
                            </select>

                            <!--<select name="driverType" lay-verify="required" required lay-search="">
                                <option value="" selected>请选择</option>
                                @for(item in jzlbList!){
                                <option value="${item.id}" ${item.id==(busPerson.driverType!)?'selected':''}>${item.name!}</option>
                                @}
                            </select>-->
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">专业类别</label>
                        <div class="layui-input-block">
                            <select name="majorType" id="majorType" xm-select="majorType" xm-select-search="" xm-select-search-type="dl" xm-select-show-count="1" lay-verify="required|cameraCheck" xm-select-skin="primary">

                            </select>
                            <!--<select name="majorType" lay-verify="required" required lay-search="">
                                <option value="" selected>请选择</option>
                                @for(item in zylbList!){
                                <option value="${item.id}" ${item.id==(busPerson.majorType!)?'selected':''}>${item.name!}</option>
                                @}
                            </select>-->
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">驾照编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="driverNumber" lay-verify="required"  placeholder="" autocomplete="off"
                                   class="layui-input" value="${busPerson.driverNumber!}">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">驾照类别</label>
                        <div class="layui-input-block">
                            <select name="driverType" lay-verify="required" required lay-search="">
                                <option value="" selected>请选择</option>
                                @for(item in jzlbList!){
                                <option value="${item.id}" ${item.id==(busPerson.driverType!)?'selected':''}>${item.name!}</option>
                                @}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">驾照分</label>
                        <div class="layui-input-block">
                            <input type="number" name="driverPoint" oninput="if(value>12)value=12" required lay-verify="required|number" placeholder=""
                                   autocomplete="off" class="layui-input" value="${busPerson.driverPoint!}">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">签发日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="issueDate" id="issueDate" lay-verify="" placeholder="请选择" autocomplete="off"
                                   class="layui-input" value="${busPerson.issueDate!}">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md12">
                        <label class="layui-form-label required">准入状态</label>
                        <div class="layui-input-block">
                            <input type="radio" name="accessStatus" if(${(busPerson.accessStatus!)}==''){ checked } ${(busPerson.accessStatus!)=='0'?'checked':''} value="0" title="有效">
                            <input type="radio" name="accessStatus" ${(busPerson.accessStatus!)=='1'?'checked':''} value="1" title="无效">
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>

    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-md">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>

</form>
<script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        laydate.render({
            elem: '#issueDate',
            type: 'date'
        });
    });

    layui.use('form', function () {
        var form = layui.form
        $ = layui.$;
    });

</script>
<script>
    layui.use(['form', 'jquery', 'select', 'code', 'element'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let VIEW_PATH = "${ctxPath}/busPerson/view/";
        let DATA_PATH = "${ctxPath}/busPerson/data/";
        let select = layui.select;

        layui.code();
        form.on('submit(user-save)', function (data) {
            $.ajax({
                url: DATA_PATH + 'saveOrUpdate',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code == 0) {
                        layer.msg("操作成功", {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("busPerson-table");
                        });
                    } else {
                        layer.msg("操作失败", {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });

        var zylb=new Array();
        @for(item in zylbList!){
            zylb.push('${item.major_type}');
        @}
        select.config('majorType',{
            type: 'get',
            header: {},
            data:{},
            success:function () {
                select.value('majorType',zylb);
            }
        })

        select.data('majorType','server',{
            url: '${ctxPath}/dict/loadCodeBook2?type='+'dict_zylb'
            ,keyword:'专业类别'
        })
    })
</script>
</body>
</html>